<template>
  <div class="appcontainer">
    <el-container>
      <!--顶部菜单-->
      <el-header>
        <span class="title">监测GIS平台</span>
        <el-menu
          :default-active="activeIndex"
          class="el-menu-demo"
          mode="horizontal"
          @select="handleSelect"
          background-color="#545c64"
          text-color="#fff"
          active-text-color="#ffd04b">
          <el-menu-item index="1">首页</el-menu-item>
          <el-menu-item index="2">项目管理</el-menu-item>
          <el-menu-item index="3">运维管理</el-menu-item>
            <el-button type="primary" @click="logout">登出</el-button>
          <el-button type="primary" @click="plus">增加</el-button>
          <el-button type="primary" @click="jian">减少</el-button>
          {{$store.getters.countValue}}
        </el-menu>
      </el-header>
      <!--中部内容-->
      <el-main>
        <router-view></router-view>
      </el-main>
      <!--底部菜单-->
      <el-footer>Footer</el-footer>
    </el-container>
  </div>

</template>

<script>
  export default {
    data() {
      return {
        activeIndex: '1',
      };
    },
    methods: {
      handleSelect(key, keyPath) {
        console.log(key)
        switch (key) {
          case '1':
            console.log(key)
            this.$router.push('/vue/home');
            console.log(key)
            break;
          case '2':
            this.$router.push('/vue/project');
            break;
          case '3':
            this.$router.push('/vue/operation');
            break;
          default:
            break;
        }
        //console.log(key, keyPath);
      },
      logout(){
        localStorage.removeItem('user');
        this.$router.push('/login');
      },
      plus(){
          this.$store.commit('increment',2);
      },
      jian(){
        this.$store.commit('jian',4);
      },
      checkLogin ()
      {
        console.log('watch')
        //检查是否存在session
        //cookie操作方法在源码里有或者参考网上的即可
        if (!localStorage.getItem('user'))
        {
          //如果没有登录状态则跳转到登录页
          this.$router.push('/login')
        }else{
          //否则跳转到登录后的页面
          this.$router.push('/vue')
        }
      }
    }
  }
</script>
<style>
  body{
    padding: 0;
    margin: 0;
  }
  html,body{
    height: 100%;
  }
</style>
<style>
  .appcontainer,section{
    height: 100%;
  }

  .title{
    color: #ffffff;
    float: left;
    width: 400px;
  }
  ul{
    margin-left: 400px;
  }
  .el-header, .el-footer {
    background-color: rgb(84, 92, 100);
    color: #333;
    text-align: center;
    line-height: 60px;
    padding: 0;
  }

  .el-aside {
    background-color: #D3DCE6;
    color: #333;
    text-align: center;
    line-height: 200px;
  }

  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
    padding: 0;
    height:100%;
  }

  body > .el-container {
    margin-bottom: 40px;
  }

  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }

  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
</style>
